function res = viewDemodSignal(obj, totalduration, varargin)
%VIEWDEMODSIGNAL Summary of this function goes here
%   Detailed explanation goes here
    p=inputParser; p.KeepUnmatched = true; p.PartialMatching = false;
    p.addRequired('totalduration',  @(x) x>0);
    
    p.addParameter('name',          'PLOTTER',             @ischar);
    p.addParameter('rate',          100,                   @(x) x>0);    
    p.addParameter('burstduration', 0.2,                   @(x) x>0);
    p.addParameter('mode',          ziEnumGridMode.Linear, @ziEnumGridMode.test);
    
    p.addParameter('average',    1,       @(x) x>0);
    
    p.addParameter('trig_device',  '',                           @(x) ismember(x, obj.deviceSerials) || isempty(x));
    p.addParameter('trig_node',    [],                           @(x) isa(x, 'ziStreamNode') || isempty(x));
    p.addParameter('edge',         ziEnumTrigEdgeSlope.Positive, @ziEnumTrigEdgeSlope.test);
    p.addParameter('level',        0.0,                          @isnumeric);
    p.addParameter('hysteresis',   0.0,                          @isnumeric);
    p.addParameter('count',        1,                            @(x) x>0);
    p.addParameter('bits',         int64(1),                     @(x) isa(x, 'int64') );
    p.addParameter('bitmask',      int64(1),                     @(x) isa(x, 'int64') );
    p.addParameter('holdofftime',  0.0,                          @(x) x>=0.0 );
    p.addParameter('holdoffcount', 0,                            @(x) x>=0 );
    p.addParameter('delay',       -0.1,                          @isnumeric );
    
    p.addParameter('update_mode',       'append',               @(x) ismember(x, {'append', 'replace'}));
    
    p.parse(totalduration, varargin{:});
    %%
    plt = obj.plotterModule(p.Results.name);
    plt.initialize();
    plt.setRate(p.Results.rate, p.Results.mode);     
    plt.setTimeGrid(p.Results.totalduration, ...
                    'burstduration', p.Results.burstduration, ...
                    'mode',          p.Results.mode);
                
    plt.setAverage(p.Results.average);
    plt.setUpdateMode(p.Results.update_mode);
    
    if ~isempty(p.Results.trig_node) && ~isempty(p.Results.trig_device)
        plt.setTrigger(p.Results.trig_device, p.Results.trig_node, ...
                       'edge',         p.Results.edge, ...
                       'level',        p.Results.level, ...
                       'hysteresis',   p.Results.hysteresis, ...
                       'count',        p.Results.count, ...
                       'bits',         p.Results.bits, ...
                       'bitmask',      p.Results.bitmask, ...
                       'holdofftime',  p.Results.holdofftime, ...
                       'holdoffcount', p.Results.holdoffcount, ...
                       'delay',        p.Results.delay); 
    end
    
    if ~isempty(obj.demodSignalNodes)
        for k = 1:size(obj.demodSignalNodes, 1)
            plt.subscribe(obj.demodSignalNodes{k, :});
        end
    else
        error('No node subscribed.');
    end
    
    res=plt.run();
    plt.unsubscribe();
end